"use strict";
const utils_request = require("./request.js");
const courseApi = {
  // 获取课程列表
  getCourseList(params) {
    return utils_request.request({
      url: "/api/course/list/page",
      method: "GET",
      data: {
        ...params,
        sortField: "createTime",
        sortOrder: "desc"
      }
    });
  },
  // 获取课程详情
  getCourseDetail(id) {
    return utils_request.request({
      url: `/api/course/get`,
      method: "GET",
      data: { id }
    });
  },
  // 报名课程
  enrollCourse(id) {
    return utils_request.request({
      url: "/api/course/enroll",
      method: "POST",
      data: id
    });
  },
  // 获取章节内容
  getChapterContent(courseId, chapter) {
    return utils_request.request({
      url: "/api/course/chapter",
      method: "GET",
      data: {
        id: courseId,
        chapter
      }
    });
  },
  // AI 对话
  chatWithAI(message) {
    return utils_request.request({
      url: "/api/AI",
      method: "POST",
      data: {
        message
      }
    });
  },
  // 保存观看记录
  saveWatchRecord(courseId, chapterId, duration) {
    return utils_request.request({
      url: "/api/course/watch/record",
      method: "POST",
      data: {
        courseId,
        chapterId,
        duration
      }
    });
  },
  // 获取观看统计
  getWatchStats() {
    return utils_request.request({
      url: "/api/course/watch/stats",
      method: "GET"
    });
  },
  // 获取推荐课程
  getRecommendCourses: () => {
    return utils_request.request({
      url: "/api/course/watch/recommend",
      method: "GET"
    });
  }
};
const userApi = {
  // ... 其他接口
  // 退出登录
  logout() {
    return utils_request.request({
      url: "/api/user/logout",
      method: "POST"
    });
  }
};
exports.courseApi = courseApi;
exports.userApi = userApi;
